<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="produce_plan" :rules="rules" label-width="100px" id="mvcfm">
      <div class="form-unit">
        <span class="mvc-title-left"> 生产计划信息 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="计划名" prop="plan_name">
              <el-input v-model="produce_plan.plan_name" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="生产产品" prop="product_id">
              {{produce_plan.product_id}}
              <el-button @click="popChoiceProduct('product_id','plan_produce')" type="success" size="mini"><i class="fa fa-edit"></i>选择</el-button>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="生产数量" prop="plan_produce_no">
              <el-input v-model="produce_plan.plan_produce_no" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <font color='#006699'>数量不要太大,否则产生生产计划时间太长</font>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="结束日期" prop="plan_produce_entry_date">
              <el-date-picker v-model="produce_plan.plan_produce_entry_date" type="date" style='width:100%' value-format="yyyy-MM-dd" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item>
              <el-button @click="planAddSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
              <el-button @click="gotoPage('/mes/produce/flow/CartogramProductionPlan?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
    </el-form>
    <el-dialog :visible.sync="ChoiceProductVisible" append-to-body>
      <ChoiceProduct v-if="ChoiceProductVisible" ref="ChoiceProduct" :popparams="popparams"> </ChoiceProduct>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import ChoiceProduct from "@/views/mes/produce/flow/ChoiceProduct";
  export default {
    name: 'PlanAdd',
    components: {
      ChoiceProduct,
    },
    props: ['popparams'],
    data() {
      return {
        ChoiceProductVisible: false,
        ChoiceProductValue: null,
        ChoiceProductDesc: null,
        vueparams: this.getVUEParams(""),
        produce_plan: {
          plan_name: null,
          product_id: null,
          plan_produce_no: null,
          plan_produce_entry_date: null,
        },
        loading: false,
        rules: {}
      }
    },
    created() {},
    updated() {},
    mounted() {},
    methods: {
      planAddSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/mes/produce/flow/ProducePlan/planAddSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/mes/produce/flow/ProduceProcessTime/produceProcessTime?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
      popChoiceProduct(desc, value) {
        this.ChoiceProductVisible = true;
        this.ChoiceProductDesc = desc;
        this.ChoiceProductValue = value;
      },
      closeChoiceProduct(value, desc) {
        this.ChoiceProductVisible = false;
        this.$set(this.produce_plan, this.ChoiceProductDesc, desc);
        this.$set(this.produce_plan, this.ChoiceProductValue, value);
      },
    },
  }
</script>
